package uit.comstore.controller;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import uit.comstore.model.blo.CustomerBLO;
import uit.comstore.model.entity.Customer;
import uit.comstore.model.blo.ProductBLO;
import uit.comstore.model.entity.Product;
import uit.comstore.utils.Order;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class OrderAction extends ActionSupport {
	private ProductBLO productBLO;
	private List<Order> orderList;
	private Long id;
	private int quantity;
	
	
	public OrderAction(){
		orderList = new ArrayList<Order>();
		productBLO = new ProductBLO() ;
	}
	

	public List<Order> getOrderList() {
		return orderList;
	}

	public void setOrderList(List<Order> orderList) {
		this.orderList = orderList;
	}

	public String execute(){
		return "success";
	}

	public String cart()
	{	
		System.out.println(getQuantity());
		System.out.println(getId());
		Product pro = productBLO.getById(getId());
		Order order = new Order(pro,getQuantity() );
		
		this.orderList.add(order);
		Map session = ActionContext.getContext().getSession();
		session.put("OrderList", orderList );
		
		
		return "success";		
	}
	
	

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public String checkout()
	{
		return "success";		
	}
	
	
	
		
}
